package question0;

import java.util.stream.IntStream;

/**
 * 请实现10个线程去抢5张车票。
 */
public class Main {


    public static void main(String[] args) {
        lockMemberMethod();
        System.out.println("*************************");
        lockMemberVariable();
    }

    public static void lockMemberVariable() {
        SynchronizedMemberVariable synchronizedMemberVariable = new SynchronizedMemberVariable();
        IntStream.range(0, 10)
                .forEach(
                        i -> new Thread(synchronizedMemberVariable, "第" + i + "窗口").start()
                );
    }

    public static void lockMemberMethod() {
        SynchronizedMemberMethod synchronizedMemberMethod = new SynchronizedMemberMethod();
        IntStream.range(0, 10)
                .forEach(
                        i -> new Thread(synchronizedMemberMethod, "第" + i + "窗口").start()
                );
    }
}
